package com.drug.mingkang.service.impl;

import com.drug.mingkang.mapper.SellDetailMapper;
import com.drug.mingkang.model.SellDetail;
import com.drug.mingkang.service.SellDetailService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (SellDetail)表服务实现类
 *
 * @author wenchangjian
 * @since 2020-08-11 12:00:14
 */
@Service("sellDetailService")
public class SellDetailServiceImpl implements SellDetailService {
    @Resource
    private SellDetailMapper sellDetailMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param detailId 主键
     * @return 实例对象
     */
    @Override
    public SellDetail queryById(String detailId) {
        return this.sellDetailMapper.queryById(detailId);
    }

    /**
     * 查询多条数据
     * queryAllByLimit  零售
     * queryAllByLimits 批发
     * @return 对象列表
     */
    @Override
    public List<SellDetail> queryAllByLimit(SellDetail sellDetail) {
        return this.sellDetailMapper.queryAllByLimit(sellDetail);
    }
    @Override
    public List<SellDetail> queryAllByLimits(SellDetail sellDetail) {
        return this.sellDetailMapper.queryAllByLimits(sellDetail);
    }


    /**
     * 统计
     * @return
     */
    @Override
    public int count() {
        return sellDetailMapper.count();
    }

    /**
     * 新增数据
     *
     * @param sellDetail 实例对象
     * @return 实例对象
     */
    @Override
    public int insert(SellDetail sellDetail) {
        return this.sellDetailMapper.insert(sellDetail);
    }

    @Override
    public int insertBatch(List<SellDetail> list) {
        for (SellDetail sd:list) {
            sellDetailMapper.deleteById(sd.getSellId());
        }
        return this.sellDetailMapper.insertBatch(list);
    }

    /**
     * 修改数据
     *
     * @param sellDetail 实例对象
     * @return 实例对象
     */
    @Override
    public int update(SellDetail sellDetail) {
        return this.sellDetailMapper.update(sellDetail);
    }

    /**
     * 通过主键删除数据
     *
     * @param detailId 主键
     * @return 是否成功
     */
    @Override
    public int deleteById(String detailId) {
        return this.sellDetailMapper.deleteById(detailId);
    }

    /**
     * 查询全部
     * @param sellDetail
     * @return
     */
    @Override
    public List<SellDetail> queryAll(SellDetail sellDetail) {
        return this.sellDetailMapper.queryAll(sellDetail);
    }

}